﻿using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using Argos.Windows.Forms;

namespace Argos.Design
{
	public class MonitoringWorkflowTypeEditor : UITypeEditor
	{

		public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
		{
			using (TypeSelectorDialog dlg = new TypeSelectorDialog(Predicates.TargetMonitoringWorkflowTypeMatcher))
			{
				dlg.Text = "Select Monitoring Workflow Type";
				if (dlg.ShowDialog() == DialogResult.OK && dlg.SelectedTypes.Count > 0)
				{
					return dlg.SelectedTypes[0];
				}
			}

			return value;
		}

		public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.Modal;
		}
	}
}
